package com.woniuxy.thread;

import java.util.concurrent.TimeUnit;

class Thread1 extends Thread {
	@Override
	public void run() {
		for (int i = 0; i < 10; i++) {
//			Thread.sleep(1000);
			try {
				TimeUnit.SECONDS.sleep(1);
				System.out.println(Thread.currentThread().getName() + ":" + i);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}

public class ThreadTest1 {

	public static void main(String[] args) {
		Thread1 thread1 = new Thread1();
		thread1.start();
		
		Thread1 thread2 = new Thread1();
		thread2.start();

		for (int i = 0; i < 10; i++) {
			try {
				TimeUnit.SECONDS.sleep(1);
				System.out.println(Thread.currentThread().getName() + ":" + i);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		
		for (int i = 0; i < 1000; i++) {
			new Thread(new Runnable() {

				@Override
				public void run() {
					//增加数据到同一个ArrayList
				}
				
			}).start();
		}
		
		//输出ArrayList元素的数量  size()
		
//		new Thread().start();
	}
	
	

}
